Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle interMedia Java Classes for Servlets and JSP API Reference 10g Release 2 (10.2) Part No. B14300-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.ord.im
Class OrdMultipartFilter

`java.lang.Object
oracle.ord.im.OrdMultipartFilter`

All Implemented Interfaces:
  javax.servlet.Filter

public class OrdMultipartFilter
extends java.lang.Object
implements javax.servlet.Filter

The OrdMultipartFilter class filters form-based, file-upload servlet requests whose contents are encoded in multipart/form-data format. This class wraps a request object with an OrdMultipartWrapper object that parses the request content.

The OrdMultipartFilter class implements the javax.servlet.Filter interface in servlet 2.3. For any servlet container that supports servlet 2.3, this filter combined with the OrdMultipartWrapper object, provides transparent access to the parameters and files in the servlet request with multipart/form-data encoding.

In order to use the OrdMultipartFilter class, you will need to specify the following in the web.xml file:

      <filter>
      <filter-name>OrdMultipartFilter</filter-name>
      <filter-class>oracle.ord.im.OrdMultipartFilter</filter-class>
      <!-- optional configuration parameters
      <init-param>
        <param-name>tempDir</param-name>
        <param-value>/tmp</param-value>
        <param-name>maxMemory</param-name>
        <param-value>5000</param-value>
      </init-param>
      -->
      </filter>
      <filter-mapping>
      <filter-name>OrdMultipartFilter</filter-name>
      <url-pattern>*.jsp</url-pattern>
      </filter-mapping>

And you will need to specify the following in the JSP file:

       //
        // Get the description, location, and photograph.
        //
        String id = request.getParameter( "id" );
        String description = request.getParameter( "description" );
        String location = request.getParameter( "location" );
        OrdHttpUploadFile photo = request.getFileParameter( "photo" );

        //
        // Prepare and execute a SQL statement to insert a new row into
        // the table and return the sequence number for the new row.
        // Disable auto-commit to allow the LOB to be written correctly.
        //
        conn.setAutoCommit( false );
        PreparedStatement stmt = conn.prepareStatement(
            "insert into photo_album (id, description, location, photo) "
            "    values (?, ?, ?, ORDSYS.ORDIMAGE.INIT() )" );
        stmt.setString( 1, id );
        stmt.setString( 2, description );
        stmt.setString( 3, location );
        stmt.executeUpdate();

        //
        // Prepare and execute a SQL statement to fetch the new OrdImage
        // object from the database.
        //
        stmt = conn.prepareStatement(
                    "select photo from photo_album where id = ? for update" );
        stmt.setString( 1, id );
        OracleResultSet rset = (OracleResultSet)stmt.executeQuery();
        if ( !rset.next() )
        {
            throw new ServletException( "new row not found in table" );
        }
        OrdImage media = (OrdImage)rset.getORAData( 1, OrdImage.getORADataFactory());

        //
        // Load the photograph into the database and set the properties.
        //
        photo.loadImage(media);

        //
        // Prepare and execute a SQL statement to update the image object.
        //
        stmt = (OraclePreparedStatement)conn.prepareStatement(
                        "update photo_album set photo = ? where id = ?" );
        stmt.setORAData( 1, media );
        stmt.setString( 2 id );
        stmt.execute();
        stmt.close();

        //
        // Commit the changes.
        //
        conn.commit();

Prerequisites

In order to run interMedia methods for servlets and JSP, you will need to import classes from the oracle.ord.im package into your Java file.

You may also need to import classes from the following Java packages:

     java.sql.
     java.io.
     javax.servlet.
     javax.servlet.http.
     oracle.jdbc.
     oracle.sql.

Constructor Summary
`OrdMultipartFilter()`

Method Summary
`void` | `destroy()` Implements the javax.servlet.Filter interface destroy method that destroys the filter.
`void` | `doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)` Implements the javax.servlet.Filter interface doFilter method that handles the servlet request with multipart/form-data encoding.
`void` | `init(javax.servlet.FilterConfig config)` Implements the javax.servlet.Filter interface init method that initializes the filter.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### OrdMultipartFilter

    public OrdMultipartFilter()

Method Detail

### init

    public void init(javax.servlet.FilterConfig config)
              throws javax.servlet.ServletException

  Implements the javax.servlet.Filter interface init method that initializes the filter. The FilterConfig object can be set with initial parameters (for the tempDir and maxMemory parameters), to specify the maximum amount of memory that the contents of uploaded files can consume before the contents are stored in a temporary directory.
  Specified by:
    `init` in interface `javax.servlet.Filter`
  Parameters:
    `config` - an object of type `javax.servlet.FilterConfig`.
  Throws:
    `javax.servlet.ServletException` - if an error occurs in the servlet.

### destroy

    public void destroy()

  Implements the javax.servlet.Filter interface destroy method that destroys the filter.
  Specified by:
    `destroy` in interface `javax.servlet.Filter`

### doFilter

    public void doFilter(javax.servlet.ServletRequest request,
                         javax.servlet.ServletResponse response,
                         javax.servlet.FilterChain chain)
                  throws java.io.IOException,
                         javax.servlet.ServletException

  Implements the javax.servlet.Filter interface doFilter method that handles the servlet request with multipart/form-data encoding. This method filters the servlet request with multipart/form-data content and wraps it with the OrdMultipartWrapper object. The OrdMultipartWrapper object then parses the content and provides access to the text-based form field parameters and uploaded files.
  Specified by:
    `doFilter` in interface `javax.servlet.Filter`
  Parameters:
    `request` - the servlet request.
    `response` - the servlet response.
    `chain` - the filters that must be processed.
  Throws:
    `java.io.IOException` - if an error occurs during the IO operation.
    `javax.servlet.ServletException` - if an error occurs in the servlet.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle interMedia Java Classes for Servlets and JSP API Reference 10g Release 2 (10.2) Part No. B14300-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999, 2005, Oracle. All rights reserved.